package com.zat.mes.andrmes.dofun.qualitytest.adapter

import android.widget.TextView
import androidx.core.content.ContextCompat
import com.chad.library.adapter.base.BaseQuickAdapter
import com.chad.library.adapter.base.viewholder.BaseViewHolder
import com.zat.mes.andrmes.R
import com.zat.mes.andrmes.data.QcRecordHasBean
import com.zat.mes.andrmes.utils.SpannableStrUtil

/**
 * 质检历史
 */
class QualityHistAdapter(layoutResId: Int) :
    BaseQuickAdapter<QcRecordHasBean, BaseViewHolder>(layoutResId) {


    override fun convert(helper: BaseViewHolder, item: QcRecordHasBean) {

        helper.setText(R.id.tvNameQualityPlanItem, item?.productName)
        var styleNo = context.getString(R.string.text_style) + " " + item?.styleNo
        var color = context.getString(R.string.text_color) + " " + item?.color
        var size = context.getString(R.string.text_size) + " " + item?.size
        val textColor = ContextCompat.getColor(context, R.color.color_text_grey)
        helper.setText(
            R.id.tvStyleNoQualityPlanItem,
            SpannableStrUtil.getColorSpannable(styleNo, 3, styleNo.length, textColor)
        )
        helper.setText(
            R.id.tvColorQualityPlanItem,
            SpannableStrUtil.getColorSpannable(color, 3, color.length, textColor)
        )
        helper.setText(
            R.id.tvSizeQualityPlanItem,
            SpannableStrUtil.getColorSpannable(size, 3, size.length, textColor)
        )
        var tvProcQhis = helper.getView<TextView>(R.id.tvProcQhis)
        tvProcQhis.text = item?.procName
        var tvStatus = helper.getView<TextView>(R.id.tvStatusQhis);
        tvStatus.text = item?.statusName


    }
}